package org.oslog.webapp.web.common.utils;

import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import com.tomaer.platform.framework.sh.security.core.sysmain.model.AccessControlEntry;
import com.tomaer.platform.framework.sh.security.core.sysmain.model.User;

public final class WebUtil {

	public static User getUser(HttpServletRequest request) {
		return (User) request.getSession().getAttribute(WebKeys.COMMON_USER);
	}
	
	public static void setUser(HttpServletRequest request, User user) {
		request.getSession().setAttribute(WebKeys.COMMON_USER, user);
	}
	
	@SuppressWarnings("unchecked")
	public static Set<String> getUrlSet(HttpServletRequest request) {
		return (Set<String>) request.getSession().getAttribute(WebKeys.COMMON_URL_SET);
	}

	public static void setUrlSet(HttpServletRequest request, Set<String> set) {
		request.getSession().setAttribute(WebKeys.COMMON_URL_SET, set);
	}

	@SuppressWarnings("unchecked")
	public static Map<String,AccessControlEntry> getACEntries(HttpServletRequest request) {
		return (Map<String,AccessControlEntry>) request.getSession().getAttribute(WebKeys.COMMON_ACE_MAP);
	}

	public static void setACEntries(HttpServletRequest request, Map<String,AccessControlEntry> aceMap) {
		request.getSession().setAttribute(WebKeys.COMMON_ACE_MAP, aceMap);
	}
}
